#pragma once

#include <srs_core.hpp>

#ifdef SRS_AUTO_HDS

#include <list>

class SrsRequest;
class SrsSharedPtrMessage;
class SrsHdsFragment;
class SrsSource;

class SrsHds {
public:
    SrsHds(SrsSource* s);
    ~SrsHds();

    int on_publish(SrsRequest* req);
    int on_unpublish();

    int on_video(SrsSharedPtrMessage* msg);
    int on_audio(SrsSharedPtrMessage* msg);

private:
    int flush_mainfest();
    int flush_bootstrap();
    void adjust_windows();

private:
    std::list<SrsHdsFragment*> fragments;
    SrsHdsFragment* currentSegment;
    int fragment_index;
    SrsSharedPtrMessage* video_sh;
    SrsSharedPtrMessage* audio_sh;

    SrsRequest* hds_req;
    bool hds_enabled;
};

#endif
